import java.util.HashSet;
import java.util.Set;

public class HashMapDemo {
    public static void main(String[] args) {
        Set<Student> ss = new HashSet<>();
        //HashSet判断相同会先判断hashCode一致,然后再盘算equals一致
        //因为hashCode和equals默认都是根据对象地址来的,所以无法根据内容判定相同
        Student s1 = new Student(18,"小刘",1.76,56.3);
        Student s2 = new Student(18,"小刘",1.76,56.3);
        Student s3 = new Student(20,"小陈",1.74,53.4);
        Student s4 = new Student(19,"小赵",1.77,57.3);
        Student s5 = new Student(21,"小吴",1.79,60.2);
        System.out.println(s1.hashCode());
        System.out.println(s2.hashCode());
        System.out.println(s3);
        System.out.println(s4);
        System.out.println(s5);
        System.out.println("----------------------");
        ss.add(s1);
        ss.add(s2);
        ss.add(s3);
        ss.add(s4);
        ss.add(s5);
        ss.forEach(student -> System.out.println(student));
    }
}
